namespace AnalyStock.GrapImage;

/// <summary>
///     价格查询面板
/// </summary>
public partial class ChartCandle : UserControl
{
    private void InitializePanel_Price()
    {
        PricePanel.Visibility = Visibility.Hidden;
        PricePanel.InitializeMouseDarg(this);
    }

    public void TextPriceTable(int index)
    {
        currCandlePoints[index].TurnOverRate = currKlineData.StockInfo.Float_share > 0
            ? currCandlePoints[index].Vol / (currKlineData.StockInfo.Float_share * 10000.0f)
            : 0.0f;
        TBPrice.Text = string.Format(
            "日  期:  {0}\n" +
            "开  盘:  {1:0.00}\n" +
            "收  盘:  {2:0.00}\n" +
            "最  高:  {3:0.00}\n" +
            "最  低:  {4:0.00}\n" +
            "交易量:  {5:0}\n" +
            "增  幅:  {6:0.0}%\n" +
            "换手率:  {7:0.0}%",
            currCandlePoints[index].TextPriceTable());
    }

    private void MouseEvent_MouseDown(object sender, MouseButtonEventArgs e)
    {
        if (e.ClickCount == 2)
        {
            if (currCandlePoints.IsNullOrEmpty())
            {
                return;
            }

            if (PricePanel.IsVisible)
            {
                PricePanel.Visibility = Visibility.Hidden;
            }
            else
            {
                PricePanel.Visibility = Visibility.Visible;
            }

            e.Handled = true;
        }
    }
}